package it.yuzuojian.com.mapper;


import it.yuzuojian.com.javaBean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.HashSet;

@Mapper
@Repository
public interface ShiroMapper {
    @Select(" select * from tb_users where name=#{username}")
    public User queryUserByUsername(String username);
    @Select("select tb_roles.role_name " +
            " from tb_users ,tb_urs,tb_roles" +
            " where tb_users.id=tb_urs.uid and tb_urs.rid=tb_roles.role_id and tb_users.name=#{username}")
    public HashSet<String> queryRoleNamesByUsername(String username);
    @Select("  select tb_permissions.permission_code from tb_users ,tb_urs,tb_roles,tb_permissions,tb_rps " +
            " where tb_users.id=tb_urs.uid and tb_urs.rid=tb_roles.role_id and tb_roles.role_id=tb_rps.rid " +
            " and tb_permissions.permission_id=tb_rps.pid and tb_users.name=#{username}")
    public HashSet<String> queryPermissionsByUsername(String username);
    @Insert("insert into tb_users values(null ,#{username},#{password},null)")
    public void addUser(User user);


}
